package com.space.managegoods.config;

import cn.hutool.core.util.IdUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.space.managegoods.mapper.GoodsMapper;
import com.space.managegoods.po.GoodsInfoPO;
import com.space.managegoods.service.GoodsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author yangyaofeng
 * @version 1.0
 * @date 2023/9/13 11:11:22
 * @description
 */
@Configuration
public class InitData {
    private Logger log = LoggerFactory.getLogger(InitData.class);

    @Value("${dataPath}")
    private String dataPath;
    @Autowired
    GoodsService goodsService;

    @PostConstruct
    public void initData(){
        log.info("init data...");
        ExcelReader reader = ExcelUtil.getReader(dataPath);
        List<Map<String,Object>> readAll = reader.readAll();
        goodsService.initData(readAll);
    }
}
